<!--
 * @Author: ssj
 * @Date: 2021-06-26 17:51:15
 * @LastEditors: ssj
 * @LastEditTime: 2021-10-15 18:58:19
 * @Description: 
-->
<template>
  <div class="o-seq-render">
    <span :class="fileID != null ? 'has-file' : ''" @click="openManager">{{
      value
    }}</span>
  </div>
</template>

<script lang="ts">
import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
import { Tsrv } from '@/services';

@Component
export default class oSepRender extends Vue {
  // modify by wiz
  public compName: string = 'oSepRender';

  /**
   * props
   */
  @Prop() params: any;

  private value = null;

  private fileID = null;

  /**
   * data
   */
  @Watch('params')
  onParamsChange() {
    this.setValue();
  }

  mounted() {
    this.setValue();
  }

  openManager() {
    if (this.fileID) {
      this.params.column.params.openFileManager(this.params.row);
    }
  }

  setValue() {
    const p = this.params?.$table?.$parent?.pagerProps || null;
    if (p)
      this.value =
        this.params.seq +
        (p.currentPage ? (p.currentPage - 1) * p.pageSize : 0);

    if (this.params.property) {
      this.fileID = this.params.data['_file_info_id_'];
    } else {
      this.fileID =
        (this.params.row && this.params.row['_file_info_id_']) || null;
    }
  }
}
</script>
<style lang="scss" scoped>
.has-file {
  text-decoration: underline;
  color: var(--default-hover-font-color);
  cursor: pointer;
}
</style>
